<extend name="Layout/ins_page" />
<block name="content">
    <link href="/sap/demo.css" rel="stylesheet" type="text/css" />
    <script src="/sap/scripts/boot.js" type="text/javascript"></script>
    <div  id='fm1'>
       <fieldset id="fd1" style="border: 1px solid #e5e5e5;height: 50px">
        <legend><span></span></legend>
        <div id="fm1">
        <div class="fieldset-body" style="margin:0px 5px;">

         单号：<input type="text" class="mini-textbox" autocomplete="off" placeholder="" id="expNo" name="expNo">
                 
          <a class="mini-button" onClick="search()" ><span class="mini-button-text ">&nbsp;&nbsp;查询&nbsp;&nbsp;</span></a>  
          <a  style="float:right;" class="mini-button" onClick="exportData()"><span class="mini-button-text ">&nbsp;&nbsp;导出&nbsp;&nbsp;</span></a>
          <a  style="float:right;" class="mini-button" onClick="GetData()"><span class="mini-button-text ">&nbsp;&nbsp;批量签收&nbsp;&nbsp;</span></a>
        </div>
        
        
        
          </div>
    </fieldset>
     
        <div class="fieldset-body">

            <div id="tabs1" class="mini-tabs" activeIndex="0" style="width:100%;margin-top: 5px;overflow:auto;" plain="false"
                 buttons="#tabsButtons"
            >
                <div title="列表：" >

                   <div id="datagrid1" class="mini-datagrid" style="height:430px;width: 100%;"
                         url="/Expexception/getlist" idField="id"
                     
                        multiSelect="true"
                       
                    >

                        <div property="columns">
                        
                             <div type="checkcolumn" ></div>
                             
                            <div field="FreeTxt"  headerAlign="center"  >订单号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            
                             <div field="ShortName"  headerAlign="center"  >平台名称
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            
                             <div field="u_brand"  headerAlign="center"  >品牌
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            
                             <div field="itemcode"  headerAlign="center"  >物料编号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            
                             <div field="ItemName"  headerAlign="center"  >物料名称
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            
                            
                            <div field="U_WhsName"  headerAlign="center"  >仓库名称
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="expNo"  headerAlign="center"  >快递单号
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>

                            <div field="expCom"  headerAlign="center"  >快递名称
                                <input property="" class="mini-textbox" style="width:100%;" />
                            </div>
                            <div field="expStatus"  headerAlign="center"  >状态
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>
                            
                             <div field="startInfo"  headerAlign="center"  >开始信息
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>
                            
                             <div field="start"  headerAlign="center"  >开始时间
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>
                            
                            <div field="endInfo"  headerAlign="center"  >结束信息
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>
                            
                            <div field="end"  headerAlign="center"  >最后更新时间
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>
                            
                            <div field="update"  headerAlign="center"  >操作
                                <input property="" class="mini-textbox" style="width:100%;" />   
                            </div>


                        </div>
                    </div>
                </div>
                <!-- <div title="Tab2" iconCls="" >
                    2
                </div> -->
            </div>
        </div>
    </div>


    </body>
    <script type="text/javascript">
        mini.parse();
        var grid = mini.get("datagrid1");
        grid.setPageSize(50);
        grid.load();
		
        grid.on("drawcell", function (e) {
            var record = e.record,
                column = e.column,
                field = e.field,
                value = e.value;
				

    
			//console.log(record);
			if (field == "start") {
                 e.cellHtml = mini.formatDate(value,"yyyy-MM-dd HH:mm:ss");

            }

            if (field == "end") {
                 e.cellHtml = mini.formatDate(value,"yyyy-MM-dd HH:mm:ss");

            }

            if (field == "update") {
                e.cellHtml = '<a href="javascript:updateState(\''+record.expNo+'\')"  >确认签收</a>';
            }
		    

        });
		
		function GetSelecteds() {
			var rows = grid.getSelecteds();
			return rows;
        }
       function GetData() {    
	        //alert(888);
			var rows = grid.getSelecteds();
			var ids = [], texts = [];
			for (var i = 0, l = rows.length; i < l; i++) {
				var row = rows[i];
				ids.push(row.expNo);
			}
			//var data = {};
			var expNo= ids.join(",");
			$.ajax({
              //url: "index.php?m=&c=Order&a=listupdatestockofboc365byexcel",
			  url:"/Expexception/updateState",
              data: {expNo: expNo},
              type: "post",
              dataType:'json',
              success: function (data) {
            	  if(data.data="SUCCESS")
				  {
					  alert("更新成功");
					  var jnmpurl="index.php?m=&c=Expexception&a=explist";
	                  location.href=jnmpurl;
				   
				  }  //加入新行，马上验证新行
                
              },
              error: function (jqXHR, textStatus, errorThrown) {
				
                  alert(jqXHR.responseText);
              }
			});
			//data.text = texts.join(",");
			//alert(data.id);
			//return data;
       }
         function search(){
			 
			 
		
			var expNo = mini.get('expNo').getValue()
      	  $.ajax({
              //url: "index.php?m=&c=Order&a=listupdatestockofboc365byexcel",
			  url:"/Expexception/getlist",
              data: {expNo: expNo},
              type: "post",
              dataType:'json',
              success: function (data) {
            	  mini.unmask(document.body);
                  grid.setData(data.data);
                  grid.validateRow(newRow);   //加入新行，马上验证新行
                
              },
              error: function (jqXHR, textStatus, errorThrown) {
				
                  alert(jqXHR.responseText);
              }
          });

        }
		
		function updateState(expNo){
      	  $.ajax({
              //url: "index.php?m=&c=Order&a=listupdatestockofboc365byexcel",
			  url:"/Expexception/updateState",
              data: {expNo: expNo},
              type: "post",
              dataType:'json',
              success: function (data) {
            	  if(data.data="SUCCESS")
				  {
					  alert("更新成功");
					  var jnmpurl="index.php?m=&c=Expexception&a=explist";
	                  location.href=jnmpurl;
				   
				  }  //加入新行，马上验证新行
                
              },
              error: function (jqXHR, textStatus, errorThrown) {
				
                  alert(jqXHR.responseText);
              }
          });
			
		}
		
		
		

    var Dateformat = function(value){  
        if(value=="" || value==null){  
            return "";  
        }  
        else{  
            var tempValue = value.replace("T", " ");  
            var dateBefore = tempValue.slice(0,10);  
  
            var timeBefore = tempValue.slice(11,19);  
            var dateArray = dateBefore.split("-");  
            var timeArray = timeBefore.split(":");  
            //注意，Date对象中的getMonth() 返回0~11  
  
            var feedDate = Date.UTC(dateArray[0],dateArray[1]-1,dateArray[2],timeArray[0],timeArray[1],timeArray[2],0) + 8*60*60;  
            var now = new Date();  
            now.setTime(feedDate);  
  
            if (now.getMonth()<10){  
                var m=0;  
                m=now.getMonth()+1;  
                var month = "0" + m;  
            }else{  
                var month = now.getMonth()+1;  
            }  
  
            if (now.getDate()<10){  
                var d=0;  
                d=now.getDate()+1;  
                var date = "0" + d;  
            }else{  
                var date = now.getDate();  
            }  
            var dateAfter = now.getFullYear() + "-" + month + "-" + date;  
            //                var dateAfter = month + "月" + date + "日";  
  
            if (now.getHours()<10){  
                var hour = "0" + now.getHours();  
            }else{  
                var hour = now.getHours();  
            }  
  
            if (now.getMinutes()<10){  
                var minute = "0" + now.getMinutes();  
            }else{  
                var minute = now.getMinutes();  
            }  
            var timeAfter = hour + ":" + timeArray[1]+":"+timeArray[2];  
  
            var timeFinal = dateAfter + "  " + timeAfter;  
            return timeFinal;  
        }  
    }  



    function exportData()
	{
	        var url="index.php?m=&c=Expexception&a=download";
	        location.href=url;
	}

    </script>
    
</block>

